package com.micaelvesterlund.skeerkie.shared.util;

import java.util.List;

import com.micaelvesterlund.skeerkie.shared.domain.Goalie;
import com.micaelvesterlund.skeerkie.shared.domain.Line;
import com.micaelvesterlund.skeerkie.shared.domain.LineUp;
import com.micaelvesterlund.skeerkie.shared.domain.Player;
import com.micaelvesterlund.skeerkie.shared.domain.Team;

public class LineUpGenerator {
	public LineUp create(Team team) {
		List<Player> getPlayers = team.getPlayers();
		Player[] players = (Player[]) getPlayers.toArray(new Player[getPlayers
				.size()]);
		int pos = 0;
		Goalie goalie = new Goalie(players[pos++]);
		Line line1 = new Line(players[pos++], players[pos++], players[pos++],
				players[pos++], players[pos++]);
		Line line2 = new Line(players[pos++], players[pos++], players[pos++],
				players[pos++], players[pos++]);
		Line line3 = new Line(players[pos++], players[pos++], players[pos++],
				players[pos++], players[pos++]);
		return new LineUp(team, goalie, line1, line2, line3);
	}
}
